import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/common/xindong_methods.dart';
import 'package:xindong/res/assets_res.dart';
import 'package:xindong/routes/call/controller/xindong_call_controller.dart';
import 'package:xindong/routes/call/controller/xindong_call_rtc_controller.dart';
import 'package:xindong/routes/call/view/xindong_call_rtc_network_shitu.dart';
import 'package:xindong/utils/xindong_image_util.dart';
import 'package:xindong/widgets/xindong_avatar.dart';
import 'package:xindong/widgets/xindong_horizontal_buttons.dart';

class XinDongCallHeaderView extends StatelessWidget {
  const XinDongCallHeaderView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    const double itemHeight = 44.0;
    final double viewWidth = screenWidth / 2;
    final targetUser = XinDongCallController.to.targetUser;
    List<XinDongHorizontaButtonClass> buttonClasss = [
      XinDongHorizontaButtonClass(type: XinDongHorizontalButtonType.minimize, iconName: AssetsRes.BUTTON_SCREEN_OFF),
    ];
    // 点击事件不实现
    return GestureDetector(
      child: Container(
        height: itemHeight,
        width: double.infinity,
        margin: const EdgeInsets.only(left: 16, top: 10, right: 16, bottom: 10),
        child: Row(
          children: [
            Container(
              height: 42,
              padding: const EdgeInsets.only(left: 5, right: 10),
              constraints: BoxConstraints(maxWidth: viewWidth, minWidth: 50),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(22),
                color: DZColors.transparentButtonColor,
              ),
              child: Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  XinDongAvatar(url: targetUser.getAvatar, size: 32),
                  const SizedBox(width: 5),
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Flexible(
                        child: Text(
                          targetUser.getName,
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: const TextStyle(color: Colors.white, fontSize: 13),
                        ),
                      ),
                      const SizedBox(height: 5),
                      Text(
                        targetUser.uid,
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: const TextStyle(color: Colors.white54, fontSize: 8),
                      ),
                    ],
                  ),
                  // isFollow
                  //     ? SizedBox(width: 5)
                  //     : Container(
                  //         height: double.infinity,
                  //         width: 36.0,
                  //         child: IconButton(
                  //           onPressed: XinDongTalkProvider.instance.requestFavorite,
                  //           padding: EdgeInsets.zero,
                  //           icon: ImageHelper.assetCalling('icon_follow'),
                  //         ),
                  //       ),
                ],
              ),
            ),
            const Expanded(child: SizedBox()),
            const Opacity(opacity: 0.68, child: XinDongCallRTCNetworkShiTu()),
            const SizedBox(width: 10),
            GestureDetector(
              onTap: () => XinDongCallRTCController.to.showSmall(),
              child: Container(
                width: 38,
                height: 38,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(44),
                  color: DZColors.transparentButtonColor,
                ),
                child: ImageUtil.asset(AssetsRes.BUTTON_SCREEN_OFF, width: 24, height: 24),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
